home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 13216 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.8 KB  |  59 lines

  1. Path: ix.netcom.com!news
  2. From: jlilley@ix.netcom.com (John Lilley)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Exporting instantiated template classes in windows DLLs
  5. Date: 24 Mar 1996 04:52:04 GMT
  6. Organization: Netcom
  7. Message-ID: <4j2kdk$j4l@dfw-ixnews4.ix.netcom.com>
  8. References: <4imc8p$3kk@btmpjg.god.bel.alcatel.be>
  9. NNTP-Posting-Host: den-co25-11.ix.netcom.com
  10. Mime-Version: 1.0
  11. Content-Type: Text/Plain; charset=US-ASCII
  12. X-NETCOM-Date: Sat Mar 23 10:52:04 PM CST 1996
  13. X-Newsreader: WinVN 0.99.7
  14.  
  15. In article <4imc8p$3kk@btmpjg.god.bel.alcatel.be>, 
  16. bailleuf@btmaa.bel.alcatel.be says...
  17. >
  18. >I am experimenting with DLLs in windows 95.  
  19. >I use the MS Visual C++ 4.0 compiler.  
  20. >How can I export an instantiated template class (if that is
  21. >possible ?)
  22.  
  23. First, you must make sure that code is generated for all of the
  24. methods of the template class that you want to export, since the
  25. compiler won't generate them unless they are needed.
  26.  
  27. It may be enough to declare a class:
  28.  
  29. class EXPORT MyClassArray : public std::vector<MyClass>
  30. {
  31. private:
  32.     void unused();    // might also be needed
  33. }
  34.  
  35. // This might also be necessary
  36. MyClassArray::unused()
  37. {
  38.     // call all base class template methods that you
  39.     // want to instantiate (and export), to make
  40.     // sure that code is generated
  41. }
  42.  
  43. If that fails, I would try:
  44.  
  45. 1) Create a source file with a single function that *calls* 
  46.    all of the template functions that you want to use,
  47.    including any operators and constructor/destructor.
  48. 2) Compile the source file with your DLL.
  49. 3) Use a library listing utility or something similar to look
  50.    in the obj file produced, and get the "mangled" names for
  51.    the template class, and add EXPORT entries in the DLL .DEF file.
  52.  
  53.  
  54. Hopefully, one of these will work for you.  Sorry I don't have a
  55. definitive answer.
  56.  
  57. john lilley
  58.  
  59.